<?php
declare (strict_types = 1);

namespace app\api\controller\live;

use app\admin\model\live\LiveGoods;
use app\api\controller\Base;
use app\common\service\lib\tencentCloud\TlsSig;
use app\common\service\live\LiveService;
use think\Request;

class Live extends Base
{
    /**
     * Author:YangXinPeng
     * 直播回调
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function notify()
    {
        $data=file_get_contents('php://input');
        $params = json_decode($data,true);
        LiveService::notifyUrl($params);
    }

    /**
     * Author:Yingbo Sun
     * 直播列表
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function liveList()
    {
        $data = LiveService::liveList();
        return $this->res($data);
    }


    /**
     * Author:Yingbo Sun
     * 直播商品列表
     * @return mixed
     */
    public function liveGoodsList()
    {
        $liveId = $this->request->get('live_id');
        if (empty($liveId)) {
            $data = ['code' => 400, 'message' => '参数错误'];
            return $this->res($data);
        }
        $data = LiveService::liveGoodsList($liveId);
        return $this->res($data);
    }

    /**
     * Author:Yingbo Sun
     * 直播标题接口
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     */
    public function liveLabel()
    {
        $data = LiveService::liveLabelList();
        return $this->res($data);
    }


    public function liveById(Request $request)
    {
        $id = $request->get('live_id');
        $data = LiveService::showById($id);
        return $this->res($data);
    }


}
